﻿using System.Collections.Generic;
using Buca.Application.aBigTime.Model.BusinessObjects.Dictionary;
using Buca.Application.aBigTime.Presenter.Dictionary.BudgetSourceProperty;
using Buca.Application.aBigTime.View.Dictionary;
using Buca.Application.aBigTime.WindowsForm.FormBase;
using Buca.Application.aBigTime.WindowsForm.FormBase.PropertyGrid;

namespace Buca.Application.aBigTime.WindowsForm.FormDictionary
{
    public partial class FrmBudgetSourcePropertyList : FrmBaseCategoryList, IBudgetSourcePropertiesView
    {
        private readonly BudgetSourcePropertiesPresenter _budgetSourcePropertiesPresenter;

        public IList<BudgetSourcePropertyModel> BudgetSourceProperties
        {
            set
            {
                grdMain.DataSource = value;

                ColumnsCollection.Add(new XtraColumn { ColumnName = "BudgetSourcePropertyID", ColumnVisible = false });
                ColumnsCollection.Add(new XtraColumn { ColumnName = "BudgetSourcePropertyCode", ColumnCaption = "Mã tính chất nguồn NS", ColumnPosition = 1, ColumnVisible = true, ColumnWith = 100 });
                ColumnsCollection.Add(new XtraColumn { ColumnName = "BudgetSourcePropertyName", ColumnCaption = "Tên tính chất nguồn NS", ColumnPosition = 2, ColumnVisible = true, ColumnWith = 300 });
                ColumnsCollection.Add(new XtraColumn { ColumnName = "Description", ColumnCaption = "Mô tả", ColumnPosition = 3, ColumnVisible = true, ColumnWith = 100 });
                ColumnsCollection.Add(new XtraColumn { ColumnName = "IsSystem", ColumnVisible = false });
                ColumnsCollection.Add(new XtraColumn { ColumnName = "IsActive", ColumnVisible = false });
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="FrmBudgetSourcePropertyList"/> class.
        /// </summary>
        public FrmBudgetSourcePropertyList()
        {
            InitializeComponent();
            _budgetSourcePropertiesPresenter = new BudgetSourcePropertiesPresenter(this);
        }

        protected override void LoadDataIntoGrid()
        {
            _budgetSourcePropertiesPresenter.Display();
        }

        protected override void DeleteGrid()
        {
            new BudgetSourcePropertyPresenter(null).Delete(int.Parse(PrimaryKeyValue));
        }
    }
}
